<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>扩展运算符</title>
	</head>
	<body>
		<div>div-1</div>
		<div>div-2</div>
		<div>div-3</div>
		<div>div-4</div>
		<div>div-5</div>
		<div>div-6</div>
		<script>
			let arr=[1,2,3];
			//合并两个数组
			let arr2=[...arr,4,5,6];
			console.log(arr2);
			
			let arr3=[4,5,6];
			//早期的arr和arr3进行合并,使用concat方法
			console.log(arr.concat(arr3));
			//ES6的合并方法
			console.log([...arr,...arr3]);
			
			var divs=document.getElementsByTagName("div");
			console.log(divs);
			var arrDivs=[...divs];
			console.log(arrDivs);
			
			
			function  func(...args){
				console.log(args);
			}
			func();
			func(1);
			func(1,2);
			func([1,2,3,4,5]);
			
			let [first,...arry]=[1,2,3,4,5,6];
			console.log(first,arry);//first :1 ,arry: 2,3,4,5,6
			//let [...array,last]=[6,7,8,9];//Uncaught SyntaxError: Rest element must be last element
		</script>
	</body>
</html>
